package com.itheima.shop.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import com.itheima.shop.entity.User;

public interface UserMapper {
	
	//select * from tab_user where username = 'Jack'
		@Select(value = "select * from tab_user where username = #{username}")
		public User findByUsername(String username);
		
		//INSERT INTO `itheima_shopdb`.`tab_user`(`uid`, `username`, `password`, `name`, `email`, `telephone`, `birthday`, `sex`, `state`, `code`) VALUES (13, 'Jack', 'e10adc3949ba59abbe56e057f20f883e', '杰克', 'jack@heima.com', '13512345678', '2019-01-01', '男', 1, 'b97a0de3-85a1-4138-b035-f7963e9bbc37');
		@Insert("INSERT INTO `tab_user`(`username`, `password`, `name`, `email`, `telephone`, `birthday`, `sex`, "
				+ "`state`, `code`) VALUES (#{username},#{password},#{name},#{email},#{telephone},#{birthday},#{sex},#{state},#{code});")
		public int insert(User user);
	
	@Update("update tab_user set state=1 where code = #{code}")
	public int activate(String code);
	
	public User findById(@Param("id")int id);
}
